home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
amiga
/
gui
/
prcgntn1.lha
/
Precognition
/
source
/
TitleBox.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-23
|
5KB
|
222 lines
#include "TitleBox.h"
#include "GraphicObjectClass.h"
#include <stdlib.h>
#include <string.h>
#include "minmax.h"
#include <graphics/gfxmacros.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include "amigamem.h"
tPoint TitleBox_Location( TitleBox *self )
{
return self->Location;
}
tPoint TitleBox_SetLocation( TitleBox *self,
PIXELS LeftEdge,
PIXELS TopEdge )
{
self->Location.x = LeftEdge;
self->Location.y = TopEdge;
return self->Location;
}
tPoint TitleBox_Size( TitleBox *self )
{
return self->Size;
}
tPoint TitleBox_AskSize( TitleBox *self,
PIXELS Width,
PIXELS Height )
{
tPoint size;
size.x = MAX( Width, 6 );
size.y = MAX( Height, 6 );
return size;
}
tPoint TitleBox_SetSize( TitleBox *self,
PIXELS Width,
PIXELS Height )
{
tPoint size;
size = AskSize( self, Width, Height );
self->Size.x = size.x;
self->Size.y = size.y;
pcg_Init3DBox( &self->BoxBorder, 0,0, size.x, size.y,
self->Pens.BrightPen, self->Pens.DarkPen, NULL );
AlignText( &self->ptext, size );
return size;
}
USHORT TitleBox_DitherPattern[] = { 0x5555, 0xAAAA };
void TitleBox_Render( TitleBox *self,
RastPort *RPort )
{
PIXELS xmin, xmax, ymin, ymax;
xmin = self->Location.x;
xmax = xmin + self->Size.x - 1;
ymin = self->Location.y;
ymax = ymin + self->Size.y - 1;
SetAfPt( RPort, TitleBox_DitherPattern, 1 );
SetAPen( RPort, self->Pens.BackPen );
SetBPen( RPort, self->Pens.DarkPen );
SetDrMd( RPort, JAM2 );
RectFill( RPort, xmin, ymin, xmax, ymax );
SetAfPt( RPort, NULL, 0 );
DrawBorder( RPort, &self->BoxBorder.TopLeft, xmin, ymin );
SetDrMd( RPort, JAM1 );
SetAPen( RPort, self->Pens.BrightPen );
PrintIText( RPort, &self->ptext, xmin, ymin );
}
char *TitleBox_Title( TitleBox *self )
{
return (char*) self->ptext.IText;
}
BOOL TitleBox_SetTitle( TitleBox *self, char *title )
{
Afree(self->ptext.IText);
self->ptext.IText = Astrdup(title);
AlignText( &self->ptext, Size(self) );
return TRUE;
}
AlignInfo TitleBox_TextAlignment( TitleBox *self )
{
return self->ptext.alignment;
}
AlignInfo TitleBox_SetTextAlignment( TitleBox *self,
UBYTE Flags,
BYTE Xpad,
BYTE Ypad )
{
self->ptext.alignment.Flags = Flags;
self->ptext.alignment.Xpad = Xpad;
self->ptext.alignment.Ypad = Ypad;
AlignText( &self->ptext, Size(self) );
return self->ptext.alignment;
}
#ifdef BUILDER
#include "BuilderMethods.h"
#include "GraphicObject_Builder.h"
#include "TitleBox_coder.h"
TitleBox *TitleBox_New( TitleBox *self )
{
TitleBox *new_box = NULL;
if (new_box = Amalloc(sizeof(TitleBox)))
{
TitleBox_Init( new_box, self->Location.x, self->Location.y,
self->Size.x, self->Size.y, self->Pens, Title(self) );
GiveItAName( new_box );
}
return new_box;
}
struct BuilderMethods TitleBox_bm;
#endif
BOOL TitleBox_elaborated = FALSE;
struct GraphicObjectClass TitleBox_Class;
void TitleBoxClass_Init( struct GraphicObjectClass *class )
{
GraphicObjectClass_Init( class );
class->isa = GraphicObjectClass();
class->ClassName = "TitleBox";
class->CleanUp = NULL;
class->Location = TitleBox_Location;
class->SetLocation = TitleBox_SetLocation;
class->Size = TitleBox_Size;
class->AskSize = TitleBox_AskSize;
class->SetSize = TitleBox_SetSize;
class->SizeFlags = GraphicObject_SizeFlagsAll;
class->Render = TitleBox_Render;
class->SetTitle = TitleBox_SetTitle;
class->Title = TitleBox_Title;
class->TextAlignment = TitleBox_TextAlignment;
class->SetTextAlignment = TitleBox_SetTextAlignment;
#ifdef BUILDER
go_InitBuilderMethods( &TitleBox_bm );
TitleBox_bm.WriteCode = TitleBox_WriteCode;
TitleBox_bm.New = TitleBox_New;
class->BuilderMethods = &TitleBox_bm;
#endif
}
struct GraphicObjectClass *TitleBoxClass( void )
{
if (! TitleBox_elaborated)
{
TitleBoxClass_Init( &TitleBox_Class );
TitleBox_elaborated = TRUE;
}
return &TitleBox_Class;
}
void TitleBox_Init( TitleBox *self,
PIXELS LeftEdge,
PIXELS TopEdge,
PIXELS Width,
PIXELS Height,
pcg_3DPens Pens,
char *Label )
{
GraphicObject_Init( self );
self->isa = TitleBoxClass();
self->Pens = Pens;
self->ptext.FrontPen = Pens.BrightPen;
self->ptext.BackPen = Pens.BackPen;
self->ptext.DrawMode = JAM1;
self->ptext.ITextFont = &pcg_Topaz80;
self->ptext.IText = NULL;
self->ptext.NextText = NULL;
self->ptext.alignment.Flags = tx_XCENTER | tx_YCENTER | tx_INSIDE;
self->ptext.alignment.Xpad = STD_XPAD;
self->ptext.alignment.Ypad = STD_YPAD;
SetLocation( self, LeftEdge, TopEdge );
SetSize( self, Width, Height );
SetTitle( self, Label );
}